local pianchong = fk.CreateSkill {
    name = "SP_heg__pianchong",
}

Fk:loadTranslationTable {
    ["SP_heg__pianchong"] = "偏宠",
    [":SP_heg__pianchong"] = "出牌阶段限一次，你可以展示一名其他角色的一张手牌，" ..
    "然后你本回合使用下一张与展示牌花色/颜色相同的牌时，你令此牌不可被响应/摸一张牌。",

    ["#SP_heg__pianchong"] = "偏宠：选择一名其他角色，展示其的一张手牌",
    ["#SP_heg__pianchong-choose"] = "偏宠：选择 %src 的一张手牌展示",
    ["@SP_heg__pianchong_suit-turn"] = "偏宠花色",
    ["@SP_heg__pianchong_color-turn"] = "偏宠颜色",

    ["$SP_heg__pianchong1"] = "承君恩露于椒房，得君恩宠于万世。",
    ["$SP_heg__pianchong2"] = "后宫有佳丽三千，然陛下独宠我一人。",
}

pianchong:addEffect("active", {
    anim_type = "special",
    prompt = "#SP_heg__pianchong",
    target_num = 1,
    card_num = 0,
    can_use = function(self, player)
        return player:usedSkillTimes(pianchong.name, Player.HistoryPhase) == 0
    end,
    card_filter = Util.FalseFunc,
    target_filter = function(self, player, to_select, selected, selected_cards, card, extra_data)
        return #selected == 0 and to_select ~= player and not to_select:isKongcheng()
    end,
    on_use = function(self, room, effect)
        local player = effect.from
        local target = effect.tos[1]
        if target:isKongcheng() then return end
        local card = room:askToChooseCard(player, {
            target = target,
            prompt = "#SP_heg__pianchong-choose:" .. target.id,
            flag = "h",
            skill_name = pianchong.name,
        })
        if card then
            room:showCards(card, target)
            room:setPlayerMark(player, "@SP_heg__pianchong_suit-turn", Fk:getCardById(card):getSuitString())
            room:setPlayerMark(player, "@SP_heg__pianchong_color-turn", Fk:getCardById(card):getColorString())
        end
    end,
})

pianchong:addEffect(fk.CardUsing, {
    anim_type = "offensive",
    is_delay_effect = true,
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(pianchong.name)
        and data.card:getSuitString() == player:getMark("@SP_heg__pianchong_suit-turn")
    end,
    on_use = function(self, event, target, player, data)
        player.room:setPlayerMark(player, "@SP_heg__pianchong_suit-turn", 0)
        data.disresponsiveList = data.disresponsiveList or {}
        for _, p in ipairs(data.tos) do
            table.insertIfNeed(data.disresponsiveList, p)
        end
    end,
})

pianchong:addEffect(fk.CardUsing, {
    anim_type = "support",
    is_delay_effect = true,
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(pianchong.name)
        and data.card:getColorString() == player:getMark("@SP_heg__pianchong_color-turn")
    end,
    on_use = function(self, event, target, player, data)
        player.room:setPlayerMark(player, "@SP_heg__pianchong_color-turn", 0)
        player:drawCards(1, pianchong.name)
    end,
})

return pianchong
